<template>
    <el-dialog :title="titleMap[mode]" v-model="visible" draggable :show-fullscreen="true" :width="1200" destroy-on-close @closed="$emit('closed')">
        <el-form :model="form" :rules="rules" :disabled="mode=='show'" ref="dialogForm" label-width="200px" label-position="left">
            <el-form-item label="店铺名称" prop="name">
                <el-input v-model="form.name" clearable></el-input>
        	</el-form-item>
            <!-- <el-form-item label="LOGO" prop="logo_image">
                <sc-upload v-model="form.logo_image" icon="el-icon-picture-outline"></sc-upload>
        	</el-form-item>
            <el-form-item label="用户id" prop="user_id">
                <el-input-number v-model="form.user_id"></el-input-number>
        	</el-form-item>
            <el-form-item label="签名" prop="sign">
                <el-input v-model="form.sign" clearable></el-input>
        	</el-form-item>
            <el-form-item label="banner图片" prop="banner_image">
                <sc-upload v-model="form.banner_image" icon="el-icon-picture-outline"></sc-upload>
        	</el-form-item>
            <el-form-item label="店铺内容" prop="content">
                <el-input v-model="form.content" clearable></el-input>
        	</el-form-item> -->
            <el-form-item label="状态:0=关闭,1=正常" prop="status">
                <el-radio v-model="form.status" v-for="(item,index) in status_option" :key="index" :label="index">{{item}}</el-radio>
        	</el-form-item>
            <el-form-item label="考试状态:0=未知,1=免考,2=已考" prop="test_status">
                <el-radio v-model="form.test_status" v-for="(item,index) in test_status_option" :key="index" :label="index">{{item}}</el-radio>
        	</el-form-item>
            <el-form-item label="审核状态:0=未知,1=申请中,2=已通过,3=已拒绝" prop="apply_status">
                <el-radio v-model="form.apply_status" v-for="(item,index) in apply_status_option" :key="index" :label="index">{{item}}</el-radio>
        	</el-form-item>
            <el-form-item label="企业OR个人:1=个人,2=企业" prop="ltd_status">
                <el-radio v-model="form.ltd_status" v-for="(item,index) in ltd_status_option" :key="index" :label="index">{{item}}</el-radio>
        	</el-form-item>
            <el-form-item label="审核备注" prop="apply_ps">
                <el-input v-model="form.apply_ps" clearable></el-input>
        	</el-form-item>
            
            <el-form-item label="联系人姓名" prop="contacts_name">
                <el-input v-model="form.contacts_name" clearable></el-input>
        	</el-form-item>
            <el-form-item label="联系人手机号" prop="mobile">
                <el-input v-model="form.mobile" clearable></el-input>
        	</el-form-item>
            <el-form-item label="地址" prop="addr">
                <el-input v-model="form.addr" clearable></el-input>
        	</el-form-item>
            <el-form-item label="注册 IP" prop="register_ip">
                <el-input v-model="form.register_ip" clearable></el-input>
        	</el-form-item>
            <el-form-item label="套餐编号" prop="package_id">
                <el-input-number v-model="form.package_id"></el-input-number>
        	</el-form-item>
            <el-form-item label="过期时间" prop="expire_time">
                <el-date-picker v-model="form.expire_time" type="datetime"></el-date-picker>
        	</el-form-item>
            <el-form-item label="考试成绩" prop="exam_scores">
                <el-input-number v-model="form.exam_scores"></el-input-number>
        	</el-form-item>
            <el-form-item label="身份证号" prop="sfz">
                <el-input v-model="form.sfz" clearable></el-input>
        	</el-form-item>
            <el-form-item label="身份证正面" prop="sfz1_image">
                <sc-upload v-model="form.sfz1_image" icon="el-icon-picture-outline"></sc-upload>
        	</el-form-item>
            <el-form-item label="身份证反面" prop="sfz2_image">
                <sc-upload v-model="form.sfz2_image" icon="el-icon-picture-outline"></sc-upload>
        	</el-form-item>
            <el-form-item label="手持身份证" prop="sfz3_image">
                <sc-upload v-model="form.sfz3_image" icon="el-icon-picture-outline"></sc-upload>
        	</el-form-item>
            <el-form-item label="自我声明ID" prop="declaration_id">
                <el-input-number v-model="form.declaration_id"></el-input-number>
        	</el-form-item>
            <el-form-item label="签名照" prop="sign_image">
                <sc-upload v-model="form.sign_image" icon="el-icon-picture-outline"></sc-upload>
        	</el-form-item>
            <el-form-item label="营业执照到期日" prop="bbl_expire_time">
                <el-date-picker v-model="form.bbl_expire_time" type="datetime"></el-date-picker>
        	</el-form-item>
            <el-form-item label="金额" prop="money">
                <el-input-number v-model="form.money"></el-input-number>
        	</el-form-item>
            <el-form-item label="贝壳" prop="shell">
                <el-input-number v-model="form.shell"></el-input-number>
        	</el-form-item>
            <el-form-item label="保证金" prop="surety">
                <el-input-number v-model="form.surety"></el-input-number>
        	</el-form-item>
            <el-form-item label="积分" prop="score">
                <el-input-number v-model="form.score"></el-input-number>
        	</el-form-item>
            <el-form-item label="划拨" prop="assign">
                <el-input-number v-model="form.assign"></el-input-number>
        	</el-form-item>
            <el-form-item label="阀值" prop="threshold">
                <el-input-number v-model="form.threshold"></el-input-number>
        	</el-form-item>
            <el-form-item label="营业时间" prop="work_time">
                <el-date-picker v-model="form.work_time" type="datetime"></el-date-picker>
        	</el-form-item>
            <el-form-item label="营业类型" prop="storebusinesstype_ids">
                <el-input v-model="form.storebusinesstype_ids" clearable></el-input>
        	</el-form-item>
            <el-form-item label="营业类型" prop="storebusinesstype_text">
                <el-input v-model="form.storebusinesstype_text" clearable></el-input>
        	</el-form-item>
            <el-form-item label="可销售主分类" prop="goodscate_ids">
                <el-input v-model="form.goodscate_ids" clearable></el-input>
        	</el-form-item>
            <el-form-item label="营业商品类型" prop="goodscate_text">
                <el-input v-model="form.goodscate_text" clearable></el-input>
        	</el-form-item>
            <el-form-item label="店铺类型" prop="storetype_id">
                <el-input-number v-model="form.storetype_id"></el-input-number>
        	</el-form-item>
            <el-form-item label="信誉值" prop="credit">
                <el-input-number v-model="form.credit"></el-input-number>
        	</el-form-item>
            <el-form-item label="纬度" prop="lat">
                <el-input v-model="form.lat" clearable></el-input>
        	</el-form-item>
            <el-form-item label="经度" prop="lng">
                <el-input v-model="form.lng" clearable></el-input>
        	</el-form-item>
            <el-form-item label="最后登录IP" prop="login_ip">
                <el-input v-model="form.login_ip" clearable></el-input>
        	</el-form-item>
            <el-form-item label="最后登录时间" prop="login_time">
                <el-date-picker v-model="form.login_time" type="datetime"></el-date-picker>
        	</el-form-item>
            <el-form-item label="创建者" prop="creator">
                <el-input v-model="form.creator" clearable></el-input>
        	</el-form-item>
            <el-form-item label="更新者" prop="updater">
                <el-input v-model="form.updater" clearable></el-input>
        	</el-form-item>
            <el-form-item label="创建时间" prop="createtime">
                <el-date-picker v-model="form.createtime" type="datetime"></el-date-picker>
        	</el-form-item>
            <el-form-item label="更新时间" prop="updatetime">
                <el-date-picker v-model="form.updatetime" type="datetime"></el-date-picker>
        	</el-form-item>
            <el-form-item label="删除时间" prop="deletetime">
                <el-date-picker v-model="form.deletetime" type="datetime"></el-date-picker>
        	</el-form-item>
            <el-form-item label="可用文件占用大小KB" prop="now_filesize">
                <el-input-number v-model="form.now_filesize"></el-input-number>
        	</el-form-item>
            <el-form-item label="已用文件占用大小KB" prop="filesize">
                <el-input-number v-model="form.filesize"></el-input-number>
        	</el-form-item>
            <el-form-item label="好评" prop="good">
                <el-input-number v-model="form.good"></el-input-number>
        	</el-form-item>
            <el-form-item label="评论数" prop="comments">
                <el-input-number v-model="form.comments"></el-input-number>
        	</el-form-item>
            <el-form-item label="差评" prop="bad">
                <el-input-number v-model="form.bad"></el-input-number>
        	</el-form-item>
            <el-form-item label="收藏数" prop="likes">
                <el-input-number v-model="form.likes"></el-input-number>
        	</el-form-item>
            <el-form-item label="邀请人" prop="pid">
                <el-input-number v-model="form.pid"></el-input-number>
        	</el-form-item>
            <el-form-item label="店铺角色ID" prop="set_id">
                <el-input-number v-model="form.set_id"></el-input-number>
        	</el-form-item>
            <el-form-item label="admin_id" prop="admin_id">
                <el-input-number v-model="form.admin_id"></el-input-number>
        	</el-form-item>
            <el-form-item label="店铺二维码" prop="qr">
                <el-input v-model="form.qr" clearable></el-input>
        	</el-form-item>
            <el-form-item label="银行开户姓名" prop="bank_account_name">
                <el-input v-model="form.bank_account_name" clearable></el-input>
        	</el-form-item>
            <el-form-item label="银行账号" prop="bank_account">
                <el-input v-model="form.bank_account" clearable></el-input>
        	</el-form-item>
            <el-form-item label="银行支行名称" prop="bank_branch_name">
                <el-input v-model="form.bank_branch_name" clearable></el-input>
        	</el-form-item>
            <el-form-item label="银行支行行号" prop="bank_branch_number">
                <el-input v-model="form.bank_branch_number" clearable></el-input>
        	</el-form-item>
            <el-form-item label="微信真实姓名" prop="wechat_name">
                <el-input v-model="form.wechat_name" clearable></el-input>
        	</el-form-item>
            <el-form-item label="微信分账openid" prop="wechat_openid">
                <el-input v-model="form.wechat_openid" clearable></el-input>
        	</el-form-item>
            <el-form-item label="支付宝真实姓名" prop="ali_name">
                <el-input v-model="form.ali_name" clearable></el-input>
        	</el-form-item>
            <el-form-item label="支付宝账号" prop="ali_account">
                <el-input v-model="form.ali_account" clearable></el-input>
        	</el-form-item>
            <el-form-item label="激活码" prop="activation_code">
                <el-input v-model="form.activation_code" clearable></el-input>
        	</el-form-item>
            <el-form-item label="企业名称" prop="ltd_name">
                <el-input v-model="form.ltd_name" clearable></el-input>
        	</el-form-item>
            <el-form-item label="社会信用代码" prop="ltd_uscc">
                <el-input v-model="form.ltd_uscc" clearable></el-input>
        	</el-form-item>
            <el-form-item label="公司法人" prop="ltd_contacts">
                <el-input v-model="form.ltd_contacts" clearable></el-input>
        	</el-form-item>
            <el-form-item label="法人手机号" prop="ltd_tel">
                <el-input v-model="form.ltd_tel" clearable></el-input>
        	</el-form-item>
            <el-form-item label="证件照" prop="paper_images">
                <sc-upload-multiple v-model="form.paper_images"></sc-upload-multiple>
        	</el-form-item>

            <el-form-item label="资质照" prop="qualification_images">
                <sc-upload-multiple v-model="form.qualification_images"></sc-upload-multiple>
        	</el-form-item>

            <el-form-item label="营业执照照片" prop="bbl_image">
                <sc-upload v-model="form.bbl_image" icon="el-icon-picture-outline"></sc-upload>
        	</el-form-item>
            <el-form-item label="省id" prop="province_id">
                <el-input-number v-model="form.province_id"></el-input-number>
        	</el-form-item>
            <el-form-item label="乡镇id" prop="town_id">
                <el-input-number v-model="form.town_id"></el-input-number>
        	</el-form-item>
            <el-form-item label="公司类型:individual=个体,ordinary=普通企业" prop="ltdtype_status">
                <el-radio v-model="form.ltdtype_status" v-for="(item,index) in ltdtype_status_option" :key="index" :label="index">{{item}}</el-radio>
        	</el-form-item>
            <el-form-item label="认证费用:1=待支付,2=已支付" prop="payca_status">
                <el-radio v-model="form.payca_status" v-for="(item,index) in payca_status_option" :key="index" :label="index">{{item}}</el-radio>
        	</el-form-item>
        </el-form>
        <template #footer>
            <el-button @click="visible=false" >取 消</el-button>
            <el-button v-if="mode!='read'" type="primary" :loading="isSaveing" @click="submit()">保 存</el-button>
        </template>
    </el-dialog>
</template>

<script>
    
    export default {
        emits: ['success', 'closed'],
        
        data() {
            return {
                mode: "create",
                titleMap: {
                    read: '查看',
                    create: '新增',
                    update: '编辑',
                },
                visible: false,
                isSaveing: false,
                form: {
                    id: 0,
					name: '',
					logo_image: '',
					user_id: '',
					sign: '',
					banner_image: '',
					content: '',
					status: '',
					test_status: '',
					apply_status: '',
					ltd_status: '',
					apply_ps: '',
					views: '',
					remark: '',
					contacts_name: '',
					mobile: '',
					addr: '',
					register_ip: '',
					package_id: '',
					expire_time: '',
					exam_scores: '',
					sfz: '',
					sfz1_image: '',
					sfz2_image: '',
					sfz3_image: '',
					declaration_id: '',
					sign_image: '',
					bbl_expire_time: '',
					money: '',
					shell: '',
					surety: '',
					score: '',
					assign: '',
					threshold: '',
					work_time: '',
					storebusinesstype_ids: '',
					storebusinesstype_text: '',
					goodscate_ids: '',
					goodscate_text: '',
					storetype_id: '',
					credit: '',
					lat: '',
					lng: '',
					login_ip: '',
					login_time: '',
					creator: '',
					updater: '',
					createtime: '',
					updatetime: '',
					deletetime: '',
					now_filesize: '',
					filesize: '',
					good: '',
					comments: '',
					bad: '',
					likes: '',
					pid: '',
					set_id: '',
					admin_id: '',
					qr: '',
					bank_account_name: '',
					bank_account: '',
					bank_branch_name: '',
					bank_branch_number: '',
					wechat_name: '',
					wechat_openid: '',
					ali_name: '',
					ali_account: '',
					activation_code: '',
					ltd_name: '',
					ltd_uscc: '',
					ltd_contacts: '',
					ltd_tel: '',
					paper_images: '',
					bbl_image: '',
					province_id: '',
					town_id: '',
					ltdtype_status: '',
					payca_status: '',
                },
                rules: {
                },
				status_option:["0","1","2"],
				test_status_option:["0","1","2"],
				apply_status_option:["0","1","2","3"],
				ltd_status_option:{"1":"1","2":"2"},
				ltdtype_status_option:{"ordinary":"ordinary","individual":"individual"},
				payca_status_option:{"1":"1","2":"2"},
            }
        },
        methods: {
            open(mode='update'){
                this.mode = mode;
                this.visible = true;
                return this
            },
            submit(){
                this.$refs.dialogForm.validate(async (valid) => {
                    if (valid) {
                        this.isSaveing = true;
                        var res = await this.$API.store[this.mode].post(this.form);
                        this.isSaveing = false;
                        if(res.code == 200){
                            this.$emit('success', this.form, this.mode)
                            this.visible = false;
                            this.$message.success(res.message)
                        }else{
                            this.$alert(res.message, "提示", {type: 'error'})
                        }
                    }else{
                        return false;
                    }
                })
            },
            setData(data){
                this.$TABLE.assign(this,data);
            }
        }
    }
</script>